﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Touch2Like.SharedLibrary;
using Touch2Like.Model;
using System.Data;
using System.Data.SqlClient;

namespace Touch2Like.DAL
{
    public class AdminUserDAL
    {
        public AdminUserInfo GetByUsername(string Username)
        {
            Database db = new Database();
            SqlDataReader dr = null;
            SqlParameter[] param =
            {
                db.MakeInParam("@Username",SqlDbType.VarChar, 50, Username)
            };
            try
            {
                dr = db.RunProc("CAM_AdminUser_GetByUserName", param);
                if (dr.Read())
                {
                    AdminUserInfo info = new AdminUserInfo();
                    info.UserName = DataHelper.GetString(dr["Username"]);
                    info.Password = DataHelper.GetString(dr["Password"]);
                    return info;

                }
                else
                {
                    return null;
                }

            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                dr.Close();
                db.Close();
            }
        }
    }
}
